<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>InstancedMesh - Three.js Docs</title>
	<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
	<script src="../scripts/highlight.min.js"></script>
	<link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
	<link type="text/css" rel="stylesheet" href="../styles/page.css">
</head>
<body>
		<p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → <a href="Object3D.html">Object3D</a> → <a href="Mesh.html">Mesh</a> → </p>
	<h1 translate="no">InstancedMesh</h1>
		<section>
			<header>
				<div class="class-description"><p>A special version of a mesh with instanced rendering support. Use
this class if you have to render a large number of objects with the same
geometry and material(s) but with different world transformations. The usage
of 'InstancedMesh' will help you to reduce the number of draw calls and thus
improve the overall rendering performance in your application.</p></div>
			</header>
			<article>
				<div class="container-overview">
					<h2>Constructor</h2>
					<h3 class="name name-method" id="InstancedMesh" translate="no">new <a href="#InstancedMesh">InstancedMesh</a><span class="signature">( geometry : <span class="param-type"><a href="BufferGeometry.html">BufferGeometry</a></span>, material : <span class="param-type"><a href="Material.html">Material</a> | Array.&lt;<a href="Material.html">Material</a>></span>, count : <span class="param-type">number</span> )</span> </h3>
					<div class="method">
						<div class="description">
							<p>Constructs a new instanced mesh.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>geometry</strong>
									</td>
									<td class="description last">
										<p>The mesh geometry.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>material</strong>
									</td>
									<td class="description last">
										<p>The mesh material.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>count</strong>
									</td>
									<td class="description last">
										<p>The number of instances.</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
				<h2 class="subsection-title">Properties</h2>
				<div class="member">
					<h3 class="name" id="boundingBox" translate="no">.<a href="#boundingBox">boundingBox</a><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
					<div class="description">
						<p>The bounding box of the instanced mesh. Can be computed via <a href="InstancedMesh.html#computeBoundingBox">InstancedMesh#computeBoundingBox</a>.</p>
						<p>Default is <code>null</code>.</p>
					</div>
				</div>
				<div class="member">
					<h3 class="name" id="boundingSphere" translate="no">.<a href="#boundingSphere">boundingSphere</a><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
					<div class="description">
						<p>The bounding sphere of the instanced mesh. Can be computed via <a href="InstancedMesh.html#computeBoundingSphere">InstancedMesh#computeBoundingSphere</a>.</p>
						<p>Default is <code>null</code>.</p>
					</div>
				</div>
				<div class="member">
					<h3 class="name" id="count" translate="no">.<a href="#count">count</a><span class="type-signature"> : number</span> </h3>
					<div class="description">
						<p>The number of instances.</p>
					</div>
						<dl class="details">
							<dt class="tag-overrides"><strong>Overrides:</strong> <a href="Mesh.html#count">Mesh#count</a></dt>
						</dl>
				</div>
				<div class="member">
					<h3 class="name" id="instanceColor" translate="no">.<a href="#instanceColor">instanceColor</a><span class="type-signature"> : <a href="InstancedBufferAttribute.html">InstancedBufferAttribute</a></span> </h3>
					<div class="description">
						<p>Represents the color of all instances. You have to set its
<a href="BufferAttribute.html#needsUpdate">BufferAttribute#needsUpdate</a> flag to true if you modify instanced data
via <a href="InstancedMesh.html#setColorAt">InstancedMesh#setColorAt</a>.</p>
						<p>Default is <code>null</code>.</p>
					</div>
				</div>
				<div class="member">
					<h3 class="name" id="instanceMatrix" translate="no">.<a href="#instanceMatrix">instanceMatrix</a><span class="type-signature"> : <a href="InstancedBufferAttribute.html">InstancedBufferAttribute</a></span> </h3>
					<div class="description">
						<p>Represents the local transformation of all instances. You have to set its
<a href="BufferAttribute.html#needsUpdate">BufferAttribute#needsUpdate</a> flag to true if you modify instanced data
via <a href="InstancedMesh.html#setMatrixAt">InstancedMesh#setMatrixAt</a>.</p>
					</div>
				</div>
				<div class="member">
					<h3 class="name" id="isInstancedMesh" translate="no">.<a href="#isInstancedMesh">isInstancedMesh</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
					<div class="description">
						<p>This flag can be used for type testing.</p>
						<p>Default is <code>true</code>.</p>
					</div>
				</div>
				<div class="member">
					<h3 class="name" id="morphTexture" translate="no">.<a href="#morphTexture">morphTexture</a><span class="type-signature"> : <a href="DataTexture.html">DataTexture</a></span> </h3>
					<div class="description">
						<p>Represents the morph target weights of all instances. You have to set its
<a href="Texture.html#needsUpdate">Texture#needsUpdate</a> flag to true if you modify instanced data
via <a href="InstancedMesh.html#setMorphAt">InstancedMesh#setMorphAt</a>.</p>
						<p>Default is <code>null</code>.</p>
					</div>
				</div>
				<h2 class="subsection-title">Methods</h2>
					<h3 class="name name-method" id="computeBoundingBox" translate="no">.<a href="#computeBoundingBox">computeBoundingBox</a><span class="signature">()</span> </h3>
					<div class="method">
						<div class="description">
							<p>Computes the bounding box of the instanced mesh, and updates <a href="InstancedMesh.html#boundingBox">InstancedMesh#boundingBox</a>.
The bounding box is not automatically computed by the engine; this method must be called by your app.
You may need to recompute the bounding box if an instance is transformed via <a href="InstancedMesh.html#setMatrixAt">InstancedMesh#setMatrixAt</a>.</p>
						</div>
					</div>
					<h3 class="name name-method" id="computeBoundingSphere" translate="no">.<a href="#computeBoundingSphere">computeBoundingSphere</a><span class="signature">()</span> </h3>
					<div class="method">
						<div class="description">
							<p>Computes the bounding sphere of the instanced mesh, and updates <a href="InstancedMesh.html#boundingSphere">InstancedMesh#boundingSphere</a>
The engine automatically computes the bounding sphere when it is needed, e.g., for ray casting or view frustum culling.
You may need to recompute the bounding sphere if an instance is transformed via <a href="InstancedMesh.html#setMatrixAt">InstancedMesh#setMatrixAt</a>.</p>
						</div>
					</div>
					<h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
					<div class="method">
						<div class="description">
							<p>Frees the GPU-related resources allocated by this instance. Call this
method whenever this instance is no longer used in your app.</p>
						</div>
					</div>
					<h3 class="name name-method" id="getColorAt" translate="no">.<a href="#getColorAt">getColorAt</a><span class="signature">( index : <span class="param-type">number</span>, color : <span class="param-type"><a href="Color.html">Color</a></span> )</span> </h3>
					<div class="method">
						<div class="description">
							<p>Gets the color of the defined instance.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>index</strong>
									</td>
									<td class="description last">
										<p>The instance index.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>color</strong>
									</td>
									<td class="description last">
										<p>The target object that is used to store the method's result.</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					<h3 class="name name-method" id="getMatrixAt" translate="no">.<a href="#getMatrixAt">getMatrixAt</a><span class="signature">( index : <span class="param-type">number</span>, matrix : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span> </h3>
					<div class="method">
						<div class="description">
							<p>Gets the local transformation matrix of the defined instance.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>index</strong>
									</td>
									<td class="description last">
										<p>The instance index.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>matrix</strong>
									</td>
									<td class="description last">
										<p>The target object that is used to store the method's result.</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					<h3 class="name name-method" id="getMorphAt" translate="no">.<a href="#getMorphAt">getMorphAt</a><span class="signature">( index : <span class="param-type">number</span>, object : <span class="param-type"><a href="Mesh.html">Mesh</a></span> )</span> </h3>
					<div class="method">
						<div class="description">
							<p>Gets the morph target weights of the defined instance.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>index</strong>
									</td>
									<td class="description last">
										<p>The instance index.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>object</strong>
									</td>
									<td class="description last">
										<p>The target object that is used to store the method's result.</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					<h3 class="name name-method" id="setColorAt" translate="no">.<a href="#setColorAt">setColorAt</a><span class="signature">( index : <span class="param-type">number</span>, color : <span class="param-type"><a href="Color.html">Color</a></span> )</span> </h3>
					<div class="method">
						<div class="description">
							<p>Sets the given color to the defined instance. Make sure you set the <code>needsUpdate</code> flag of
<a href="InstancedMesh.html#instanceColor">InstancedMesh#instanceColor</a> to <code>true</code> after updating all the colors.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>index</strong>
									</td>
									<td class="description last">
										<p>The instance index.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>color</strong>
									</td>
									<td class="description last">
										<p>The instance color.</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					<h3 class="name name-method" id="setMatrixAt" translate="no">.<a href="#setMatrixAt">setMatrixAt</a><span class="signature">( index : <span class="param-type">number</span>, matrix : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span> </h3>
					<div class="method">
						<div class="description">
							<p>Sets the given local transformation matrix to the defined instance. Make sure you set the <code>needsUpdate</code> flag of
<a href="InstancedMesh.html#instanceMatrix">InstancedMesh#instanceMatrix</a> to <code>true</code> after updating all the colors.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>index</strong>
									</td>
									<td class="description last">
										<p>The instance index.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>matrix</strong>
									</td>
									<td class="description last">
										<p>The local transformation.</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
					<h3 class="name name-method" id="setMorphAt" translate="no">.<a href="#setMorphAt">setMorphAt</a><span class="signature">( index : <span class="param-type">number</span>, object : <span class="param-type"><a href="Mesh.html">Mesh</a></span> )</span> </h3>
					<div class="method">
						<div class="description">
							<p>Sets the morph target weights to the defined instance. Make sure you set the <code>needsUpdate</code> flag of
<a href="InstancedMesh.html#morphTexture">InstancedMesh#morphTexture</a> to <code>true</code> after updating all the influences.</p>
						</div>
						<table class="params">
							<tbody>
								<tr>
									<td class="name">
										<strong>index</strong>
									</td>
									<td class="description last">
										<p>The instance index.</p>
									</td>
								</tr>
								<tr>
									<td class="name">
										<strong>object</strong>
									</td>
									<td class="description last">
										<p>A mesh which <code>morphTargetInfluences</code> property containing the morph target weights
of a single instance.</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				<h2 class="subsection-title">Source</h2>
				<p>
					<a href="https://github.com/mrdoob/three.js/blob/master/src/objects/InstancedMesh.js" translate="no" target="_blank" rel="noopener">src/objects/InstancedMesh.js</a>
				</p>
			</article>
		</section>
<script src="../scripts/linenumber.js"></script>
<script src="../scripts/page.js"></script>
</body>
</html>